﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Code.Models;
using Code.BLL;
using Company.Web.Models.HomeModels;

namespace Company.Web.Controllers
{
    [HandleError]
    public class HomeController : ControllerBase
    {
        public ActionResult Index(Language? l)
        {
            if (l.HasValue)
            {
                return RedirectToAction("companyprofile", new { l = l.Value.Lower() });
            }
            var model = new IndexModel();
            model.LeftImgs = (CommenManage.Options[OptionKey.Site_Home_IndexImgs_Ch].Value ?? "").Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            model.RightImgs = (CommenManage.Options[OptionKey.Site_Home_IndexImgs_En].Value ?? "").Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            return View(model);
        }

        public ActionResult CompanyProFile(Language l)
        {
            var model = new CommenManage<Option>().GetTable<Option>().Where(p => p.Key == "Site_Html_" + ContentType.CompanyProfile + "_" + l).Select(p => p.Value).FirstOrDefault() ?? "";
            return View("CompanyProFile_" + l, model as object);
        }

        public ActionResult Services(Language l)
        {
            var model = new CommenManage<Option>().GetTable<Option>().Where(p => p.Key == "Site_Html_" + ContentType.Services + "_" + l).Select(p => p.Value).FirstOrDefault() ?? "";
            return View("Services_" + l, model as object);
        }

        public ActionResult QualityControl(Language l)
        {
            var model = new CommenManage<Option>().GetTable<Option>().Where(p => p.Key == "Site_Html_" + ContentType.QualityControl + "_" + l).Select(p => p.Value).FirstOrDefault() ?? "";
            return View("QualityControl_" + l, model as object);
        }

        public ActionResult ContactUs(Language l)
        {
            var model = new CommenManage<Option>().GetTable<Option>().Where(p => p.Key == "Site_Html_" + ContentType.ContactUs + "_" + l).Select(p => p.Value).FirstOrDefault() ?? "";
            return View("ContactUs_" + l, model as object);
        }

        public ActionResult WebState()
        {

            return View();
        }
    }
}
